import time
def read_from_line(filename):
    file = open(filename)
    data = file.readlines()
    data = list(map(int, data))
    return data
def bubble_sort(data):
    for i in range(len(data)):
        is_sorted = True
        for j in range(0, len(data) - i - 1):
            if data[j] > data[j +  1]:
                is_sorted = False
                data[j], data[j + 1] = data[j + 1], data[j]
        if is_sorted:
            return
m1 = read_from_line('m1_sorted.txt')
t_start_m1 = time.time()
bubble_sort(m1)
t_finish_m1 = time.time()
time_m1 = round((t_finish_m1 - t_start_m1) * 1000)
print(f'm1_sorted {time_m1} milliseconds')

m2 = read_from_line('m2_reverse.txt')
t_start_m2 = time.time()
bubble_sort(m2)
t_finish_m2 = time.time()
time_m2 = round((t_finish_m2 - t_start_m2) * 1000)
print(f'm2_reverse {time_m2} milliseconds')

m3 = read_from_line('m3_shuffle.txt')
t_start_m3 = time.time()
bubble_sort(m3)
t_finish_m3 = time.time()
time_m3 = round((t_finish_m3 - t_start_m3) * 1000)
print(f'm3_shuffle {time_m3} milliseconds')
